package org.particlethink.request;

import io.swagger.v3.oas.annotations.media.Schema;
import org.particlethink.entry.PlanTyp;
import org.particlethink.model.PlanMaterial;

public class PlanMaterialRequest {
    @Schema(description = "物料id")
    private int materialId;//物料id
    @Schema(description = "计划数量")
    private int expectNum;//计划数量
    @Schema(description = "备注")
    private String remark;//备注

    @Schema(description = "供货商id（仅用户创建批次计划）")
    private int supplierId;//供货商id
    @Schema(description = "使用部位（仅用户创建批次计划）")
    private String purpose;//使用部位


    public PlanMaterial toPlanMaterial(int planId, PlanTyp typ) {
        return new PlanMaterial(materialId, planId, typ, expectNum, remark);
    }

    public PlanMaterial UpdateOrCreatePlanMaterial(PlanMaterial planMaterial, int planId, PlanTyp typ) {
        if (planMaterial == null) {
            return new PlanMaterial(materialId, planId, typ, expectNum, remark);
        }
        planMaterial.setExpectNum(expectNum);
        planMaterial.setRemark(remark);
        planMaterial.setSupplierId(supplierId);
        planMaterial.setPurpose(purpose);
        return planMaterial;
    }

    public PlanMaterial toBatchPlanMaterial(int planId, PlanTyp typ) {
        return new PlanMaterial(materialId, planId, typ, expectNum, supplierId, purpose, remark, 0);
    }

    public int getMaterialId() {
        return materialId;
    }

    public void setMaterialId(int materialId) {
        this.materialId = materialId;
    }

    public int getExpectNum() {
        return expectNum;
    }

    public void setExpectNum(int expectNum) {
        this.expectNum = expectNum;
    }

    public int getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(int supplierId) {
        this.supplierId = supplierId;
    }

    public String getPurpose() {
        return purpose;
    }

    public void setPurpose(String purpose) {
        this.purpose = purpose;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
}
